//
//  CLoadingW.m
//  FrameWork
//
//  Created by waver on 10-8-5.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CLoadingW.h"


@implementation CLoadingW

@synthesize loadingOver = __loadingOver;

static CLoadingW* __self = nil;

+(id)ShareLoading;
{
	if(__self == nil)
	{
		__self = [[CLoadingW node] initSprite];
	}
	
	return __self;
}

-(id)initSprite
{
	__backSprite = [CCSprite spriteWithTexture:
					[[CCTextureCache sharedTextureCache] addImage:@"juqing_back.png"]];
	__wordSprite = [CCSprite spriteWithTexture:
					[[CCTextureCache sharedTextureCache] addImage:@"loading.png"]];
	__infoSprite = [CCSprite spriteWithTexture:
					[[CCTextureCache sharedTextureCache] addImage:@"Loading_Word_changban.png"]];
	[self addChild:__backSprite z:1];
//	[self addChild:__wordSprite z:10];
	[self addChild:__infoSprite z:5];
	
	__infoSprite.position = CGPointMake(240, 0-98);
	
	CGPoint backPoint =CGPointMake(240, 160);
	CGPoint wordPoint = CGPointMake(400,320-280);
	__backSprite.position = backPoint;
	__wordSprite.position = wordPoint;
	
	id action = [CCFadeOut actionWithDuration:2.0];
	
	id seq = [CCSequence actions:action,nil];
	
	[__wordSprite runAction:[CCRepeatForever actionWithAction:seq]];
	
	id actionMove = [CCMoveBy actionWithDuration:2 position:ccp(0,250)];
	id	action2 = [CCMoveBy actionWithDuration:2 position:ccp(0,0)];
	id seqInfo =[CCSequence actions:
				 actionMove,
				 action2,
				 [CCCallFunc actionWithTarget:self selector:@selector(CallBack)],
				 action2,
				 nil];
	
	[__infoSprite runAction:[CCRepeatForever actionWithAction:seqInfo]];
	
	return self;
}


-(void)CallBack
{
	__loadingOver = YES;
}

@end
